package com.lianjia.sh.tools.msg.v1.sender.impl;

import com.lianjia.sh.tools.msg.v1.model.Msg;
import com.lianjia.sh.tools.msg.v1.sender.Sender;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by yangsp1 on 16/6/24.
 */
public class SenderCompositeImpl implements Sender {
    Set<Sender> senders = new HashSet<>();

    @Override
    public boolean send(Msg msg) {
        for(Sender sender : senders){
            if(sender.isMatch(msg)) {
                sender.send(msg);
            }
        }
        return true;
    }

    @Override
    public boolean isMatch(Msg msg) {
        return true;
    }

    public Set<Sender> getSenders() {
        return senders;
    }

    public void setSenders(Set<Sender> senders) {
        this.senders = senders;
    }
}
